package colicious.service;

import java.util.List;

import colicious.domain.Order;
import colicious.repository.OrderDao;



public class SimpleOrderManager implements OrderManager {

	private OrderDao orderDao;

	// Returns the order list
	public List<Order> getOrders() {
		return orderDao.getOrderList();
	}
	
	public void increasePrice(int percentage) {

		List<Order> orders = orderDao.getOrderList();

		if (orders != null) {
			for (Order order : orders) {
				double newPrice = order.getPrice().doubleValue() * (100 + percentage)/100;
				order.setPrice(newPrice);
				orderDao.saveOrder(order);
			}
		}
	}
	
	public void setOrderDao(OrderDao orderDao) {
		this.orderDao = orderDao;
	}
}